home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 April / PCWorld_2008-04_cd.bin / komercni software / miton / SystemMechanic7Pro.exe / {app} / smhtml.dll / 1033 / HTML / OVERVIEW.JS < prev    next >
Text File  |  2008-01-24  |  15KB  |  660 lines

  1.  
  2.     
  3.     function OverviewPageOnLoad()
  4.     {
  5.     
  6.       SetHintsAndTipsVisible(false);
  7.     SetRepairButtonCaption(btLOC_O_RepairAllNow);
  8.     
  9.     SetViewProblemsButtonCaption(btLOC_O_ViewProblems);
  10.     
  11.     SetSubscriptionButtonCaption(btLOC_ManageMyAccount);
  12.     
  13.  
  14.  
  15.     var  b = new ActionButton()
  16.     b.ID = "btnspAnalyze";
  17.     b.Type = ACTION_BUTTON_CUSTOM_DROPDOWN;
  18.     b.Text = btLOC_O_AnalyzeNow;
  19.     b.Event = "external.DoOnAnalyzeButtonClick();";
  20.     b.Event2 = "_AnalysisDrowMenu('spAnalyze');";
  21.     b.Class = "button";
  22.     b.FloatClass = "floatL";
  23.     b.Width = btLOC_O_AnalyzeNow_width;
  24.     Get('spAnalyze').innerHTML  =  b.Render();
  25.  
  26.      
  27.  }
  28.  
  29.  
  30. // Call it when page load
  31. AddLoadEvent(OverviewPageOnLoad);
  32.  
  33.  
  34. var Overall_Unknown    = "0";
  35. var Overall_Critical    = "1";
  36. var Overall_Poor     = "2";
  37. var Overall_Fair     = "3";
  38. var Overall_Good     = "4";
  39.  
  40.  
  41. var UpdateStatus_UptoDate = "0";
  42. var UpdateStatus_Available = "1";
  43. var UpdateStatus_CouldNotConnect = "2";
  44. var UpdateStatus_UnKnown = "3";
  45. var UpdateStatus_Restart = "4";
  46.  
  47. var UpdateButton_CheckForUpdates = "0";
  48. var UpdateButton_Download = "1";
  49. var UpdateButton_Install = "2";
  50. var UpdateButton_TryAgain = "3";
  51. var UpdateButton_Restart = "4";
  52.  
  53.  
  54. var SubscriptionStatus_Good = "0";
  55. var SubscriptionStatus_ExpireSoon = "1";
  56. var SubscriptionStatus_Expired = "2";
  57. var SubscriptionStatus_Blue = "3";
  58.  
  59. var SubscriptionButton_Manage = "0";
  60. var SubscriptionButton_Extend = "1";
  61. var SubscriptionButton_Renew = "2";
  62.  
  63. function ProductStatus()
  64. {
  65.  this.DivClass = "";
  66.  this.StatusClass = "";
  67.  this.Image = "";
  68. }
  69.  
  70.  
  71.  
  72.  function SetSubscriptionOptionsLinkVisible(Value)
  73.  {
  74.    SetDisplayWidget('spOptions', Value);
  75.  }
  76.  
  77. function DoOnSubscriptionOptionsLinkClicked()
  78. {
  79.   var x = findPosX("spOptions");
  80.   var y = findPosY("spOptions")  + 20 - GetScrollTop() - 5 ;
  81.   external.DoOnSubscriptionOptionsLinkClicked(x, y);
  82. }
  83.  
  84.  
  85.  //*************** Meters ***************************//
  86.  
  87.  
  88. function SetOverallTackLevel(Level)
  89. {
  90.    var o =  _GetMeterOverallImage(Level);
  91.   Get('imgMeterOverall').src = o.Image;
  92.   Get('tdOverall').className = o.DivClass;
  93.   Get('divOverallHeadingText').className = o.StatusClass;
  94. }
  95.  
  96. function SetHealthTackLevel(Level)
  97. {
  98.   Get('imgMeterHealth').src = _GetMeterHealthImage(Level);
  99. }
  100.  
  101. function SetSecurityTackLevel(Level)
  102. {
  103.   Get('imgMeterSecurity').src = _GetMeterSecurityImage(Level);
  104. }
  105.  
  106. function SetSystemStatusHeading(Heading)
  107. {
  108.   Get('divOverallHeadingText').innerHTML = URLDecode(Heading);
  109. }
  110.  
  111. function SetSystemStatusDetails(Details)
  112. {
  113.   Get('pOverallDetailsText').innerHTML = URLDecode(Details);
  114. }
  115.  
  116. function SetLastAnalysisText(AnalysisText)
  117. {
  118.   Get('divLastAnalysisText').innerHTML = AnalysisText;
  119. }
  120. function SetReanalyzeLinkVisible(Visible)
  121. {
  122.   SetDisplayWidget('aReAnalyzeLink', Visible);
  123. }
  124.  
  125. function SetAnalyzeButtonVisible(Visible)
  126. {
  127.   SetDisplayWidget('spAnalyze', Visible);
  128. }
  129.  
  130. function SetRepairButtonVisible(Visible)
  131. {
  132.   SetDisplayWidget('spRepairAll', Visible, true);
  133. }
  134.  
  135. //Visible : bool
  136. function SetViewProblemsVisible(Visible)
  137. {
  138.   SetDisplayWidget('spViewAll', Visible, true);
  139. }
  140.  
  141.  
  142. // Sets the caption text of the View Problems button
  143. function SetViewProblemsButtonCaption(Value)
  144. {
  145.       b = new ActionButton()
  146.     b.ID = "btnViewAlll";
  147.     b.Type = ACTION_BUTTON_CUSTOM;
  148.     b.Text = Value; // "View Problems";
  149.     b.Event = "external.DoOnViewProblemClick();";
  150.     b.Class = "button";
  151.     b.FloatClass = "floatL";
  152.     b.Width = btLOC_O_ViewProblems_width;
  153.     Get('spViewAll').innerHTML  =  b.Render();
  154.   
  155. }
  156.  
  157. // Sets the caption text of the Repair button
  158. function SetRepairButtonCaption(Value)
  159. {
  160.  
  161.        var b = new ActionButton()
  162.     b.ID = "btnButtonRepairAll";
  163.     b.Type = ACTION_BUTTON_CUSTOM;
  164.     b.Text = Value; //"Repair All Now";
  165.     b.Event = "external.DoOnRepairButtonClick();";
  166.     b.Class = "button_highlighted";
  167.     b.FloatClass = "floatL";
  168.     b.Width = btLOC_O_RepairAllNow_width;
  169.     Get('spRepairAll').innerHTML  =  b.Render();
  170.     
  171.  
  172. }
  173.  
  174.  
  175.  
  176. //*************** End Meters ***************************//
  177.  
  178. //*************** Update widget ***************************//
  179.  
  180.  
  181. function SetSubscriptionDetailsText(Text)
  182. {
  183.   Get('spSubscriptionDetails').innerHTML = URLDecode(Text);
  184. }
  185.  
  186. var x = 0;
  187.  
  188. function SetSubscriptionButtonCaption(Value)
  189. {
  190.  var b = new ActionButton();
  191.   b.ID = "btnSubscriptionButton";
  192.   b.Type = ACTION_BUTTON_CUSTOM;
  193.   b.Class = "button";
  194.   b.FloatClass = "floatR";
  195.   b.Width = btLOC_ManageMyAccount_width;
  196.   b.Event = "external.DoOnSubscriptionButtonClicked(x);";
  197.   
  198.   
  199.   b.Text = Value; //btLOC_ManageMyAccount;
  200.       
  201.  
  202.  Get('pSubscriptionButton').innerHTML = b.Render();
  203. }
  204.  
  205. function SetSubscriptionButtonVisible(Visible)
  206. {
  207.  SetDisplayWidget('pSubscriptionButton', Visible);
  208.  
  209.  
  210. function SetSubscriptionButtonID(Value)
  211. {
  212.  x = Value;
  213. }
  214. //*************** End Update ***************************//
  215.  
  216. //*************** Tips ***************************//
  217.  
  218. var topcount = 0;
  219.  
  220. function AddOverviewTip(ID, Text, LinkText)
  221. {
  222.    var  t = new Tip(ID);
  223.    t.Text = URLDecode( Text );
  224.    t.LinkText = LinkText;
  225.    Get("divTips").innerHTML += t.Render();
  226.    topcount ++;
  227. }
  228.  
  229. function ClearOverviewTips()
  230. {
  231.    Get("divTips").innerHTML = "";
  232.    topcount = 0;
  233.    
  234.    //alert( Get("divTips").innerHTML );
  235. }
  236.  
  237. function SetOverviewTipVisible(ID, Value)
  238. {
  239.   var  t = new Tip(ID);
  240.   t.SetDisplay(Value);
  241. }
  242. //*************** End Tips ***************************//
  243.  
  244.  
  245.  
  246. //******************** Hints widget ***************************
  247.  
  248.  var ArrayHintsButtons = new Array();
  249.  
  250. function HintButtonParameters()
  251. {
  252.   this.ID = "";
  253.   this.Text = "";
  254.   this.Event = "";
  255.   this.Width = 73;
  256. }
  257.  
  258.  
  259. // TagId : ip if the tag that button gonne be rendered
  260. // Text : Button text
  261. // Event : onclick event
  262. // Width : width of the butttton (Int)
  263. function AddHintButtonParameters(TagId, Text, Event, Width)
  264. {
  265.   var h = new HintButtonParameters();
  266.   h.ID = TagId || "";
  267.   h.Text = Text || "";
  268.   h.Event = Event || "";
  269.   h.Width = Width || 73;
  270.   
  271.   if(( h.ID != "") && (h.Text != "") )
  272.     ArrayHintsButtons[ArrayHintsButtons.length] = h; 
  273. }
  274.  
  275.  
  276.  function SetHintButton()
  277.   {
  278.   
  279.    var sp = Get("spHintButtonParameters");
  280.     if( sp!=null)
  281.     {
  282.       var arr = sp.getElementsByTagName("span");
  283.       for(var x=0; x< arr.length; x++)
  284.       {
  285.         var arr1 = arr[x].innerHTML.split("|");
  286.          if( arr1.length == 3)
  287.            AddHintButtonParameters(arr1[0], arr1[1], "", arr1[2]);
  288.       }
  289.     }
  290.     
  291.     
  292.     for(var x=0; x< ArrayHintsButtons.length; x++)
  293.     {
  294.       var a = new ActionButton();
  295.       a.Type = ACTION_BUTTON_CUSTOM;
  296.       a.ID = ArrayHintsButtons[x].ID;
  297.       a.FloatClass = "floatR";
  298.       a.Width = ArrayHintsButtons[x].Width;
  299.       if( ArrayHintsButtons[x].Event!= "")
  300.           a.Event = ArrayHintsButtons[x].Event;
  301.       a.Text = ArrayHintsButtons[x].Text;
  302.       
  303.       Get(ArrayHintsButtons[x].ID).innerHTML = a.Render();
  304.       
  305.     } 
  306.   }
  307.  
  308.  
  309.  
  310. //value : bool
  311. function SetHintsAndTipsVisible( value )
  312. {
  313.  SetDisplayWidget("divHintsWidget", value );
  314. }
  315.  
  316.  
  317. //Html : string
  318. function SetHintsAndTipsContent( Html )
  319. {
  320.    try
  321.    {
  322.    var h  = Get( "divHints" );
  323.   h.innerHTML =  URLDecode( Html );
  324.   SetHintsAndTipsVisible(true);
  325.   
  326.   }
  327.   catch(e)
  328.   {
  329.   SetHintsAndTipsVisible(false);
  330.   }
  331.   
  332.    try
  333.   {
  334.   SetHintButton();
  335.   }catch(e)
  336.   {
  337.   }
  338. }
  339.  
  340. // height : string
  341. function SetHintsAndTipsHeight( height )
  342. {
  343.    var h  = Get( "divHints" );
  344.   h.style.height = height;
  345. }
  346.  
  347. //disable/enable the Y scroll bar
  348. //value : bool
  349. function SetHintsAndTipsScrollY( value )
  350. {
  351.    var h  = Get( "divHints" );
  352.    if( value )
  353.      h.style.overflowY = "scroll";
  354.    else
  355.      h.style.overflowY = "auto";
  356. }
  357.  
  358.  
  359. //******************** End Hints widget ***************************
  360.  
  361.  
  362.  
  363.  
  364. //*********************  overview internal functions ***********************//
  365.  
  366. function _GetMeterOverallImage(Level)
  367. {
  368.  var  u = new ProductStatus();
  369.  
  370.   switch ( Level )
  371.     { 
  372.      case Overall_Unknown :
  373.       u.Image =  "O_tack_overall_unknown.jpg";
  374.       u.DivClass = "overview_unknown";
  375.       u.StatusClass = "system_status gray";
  376.       break;
  377.      case Overall_Critical :
  378.       u.Image =  "O_tack_overall_critical.jpg";
  379.       u.DivClass = "overview_critical";
  380.       u.StatusClass = "system_status red";
  381.       break;
  382.      case Overall_Poor :
  383.       u.Image =  "O_tack_overall_low.jpg";
  384.       u.DivClass = "overview_low";
  385.       u.StatusClass = "system_status orange";
  386.       break;
  387.      case Overall_Fair :
  388.       u.Image =  "O_tack_overall_fair.jpg";
  389.       u.DivClass = "overview_fair";
  390.       u.StatusClass = "system_status yellow";
  391.       break;
  392.      case Overall_Good :
  393.       u.Image =  "O_tack_overall_good.jpg";
  394.       u.DivClass = "overview_good";
  395.       u.StatusClass = "system_status green";
  396.       break;
  397.   }
  398.   
  399.   return u;
  400. }
  401.  
  402. function _GetMeterHealthImage(Level)
  403. {
  404.   switch ( Level )
  405.     { 
  406.      case Overall_Unknown :
  407.       return  "O_tack_health_unknown.jpg";
  408.       break;
  409.      case Overall_Critical :
  410.       return   "O_tack_health_critical.jpg";
  411.       break;
  412.      case Overall_Poor :
  413.       return   "O_tack_health_low.jpg";
  414.       break;
  415.      case Overall_Fair :
  416.       return  "O_tack_health_fair.jpg";
  417.       break;
  418.      case Overall_Good :
  419.       return   "O_tack_health_good.jpg";
  420.       break;
  421.   }
  422. }
  423.  
  424. function _GetMeterSecurityImage(Level)
  425. {
  426.   switch ( Level )
  427.     { 
  428.      case Overall_Unknown :
  429.       return "O_tack_security_unknown.jpg";
  430.       break;
  431.      case Overall_Critical :
  432.       return "O_tack_security_critical.jpg";
  433.       break;
  434.      case Overall_Poor :
  435.       return "O_tack_security_low.jpg";
  436.       break;
  437.      case Overall_Fair :
  438.       return "O_tack_security_fair.jpg";
  439.       break;
  440.      case Overall_Good :
  441.       return "O_tack_security_good.jpg";
  442.       break;
  443.   }
  444. }
  445.  
  446. function _GetUpdateStatusClass(UpdateStatus)
  447. {
  448.   var  u = new ProductStatus();
  449.   switch ( UpdateStatus )
  450.     { 
  451.      case UpdateStatus_UptoDate :
  452.       u.DivClass = "update_green";
  453.       u.StatusClass = "status green";
  454.       return u;
  455.       break;
  456.      case UpdateStatus_Available :
  457.       u.DivClass = "update_blue";
  458.       u.StatusClass = "status blue";
  459.       return u;
  460.      case UpdateStatus_CouldNotConnect :
  461.       u.DivClass = "update_red";
  462.       u.StatusClass = "status red";
  463.       return u;
  464.      case UpdateStatus_UnKnown :
  465.       u.DivClass = "update_gray";
  466.       u.StatusClass = "status gray";
  467.       return u;
  468.      case UpdateStatus_Restart :
  469.       u.DivClass = "update_orange";
  470.       u.StatusClass = "status yellow";
  471.       return u;
  472.   }
  473. }
  474.  
  475.  
  476. function _AnalysisDrowMenu(imgID)
  477. {
  478.   var x = findPosX( imgID );
  479.   var y = findPosY( imgID )  + 20 - GetScrollTop() + 2 ;
  480.   
  481.   //moveDiv("move", x, y);
  482.   external.DoOnAnalyzeDropDownClick(x, y );
  483. }
  484.  
  485.  
  486. function _ReAnalysisDrowMenu(LinkID)
  487. {
  488.   var x = findPosX( LinkID );
  489.   var y = findPosY( LinkID )  + 20 - GetScrollTop() - 5 ;
  490.   //moveDiv("move", x, y);
  491.  external.DoOnReanalyzeLinkClick(x, y );
  492. }
  493.  
  494.  
  495. function _GetUpdateButton(ButtonStatus)
  496. {
  497.   
  498.   var b = new ActionButton();
  499.   b.ID = "btnUpdateButton";
  500.   b.Type = ACTION_BUTTON_CUSTOM;
  501.   b.Class = "button";
  502.   b.Width = 93;
  503.   b.Event = "external.DoOnUpdateButtonClick('" + ButtonStatus + "');";
  504.    switch ( ButtonStatus )
  505.     { 
  506.      case UpdateButton_CheckForUpdates :
  507.       b.Text = btLOC_CheckforUpdates;
  508.       b.Width = btLOC_CheckforUpdates_width;
  509.       return b;
  510.       break;
  511.      case UpdateButton_Download :
  512.       b.Text = btLOC_DownloadNow;
  513.       b.Width = btLOC_DownloadNow_width;
  514.       return b;
  515.      case UpdateButton_Install :
  516.       b.Text = btLOC_InstallNow;
  517.       b.Width = btLOC_InstallNow_width;
  518.       return b;
  519.      case UpdateButton_TryAgain :
  520.       b.Text = btLOC_TryAgain;
  521.       b.Width = btLOC_TryAgain_width;
  522.       return b;
  523.      case UpdateButton_Restart :
  524.       b.Text = btLOC_CheckforUpdates;
  525.       b.Width = btLOC_CheckforUpdates_width;
  526.       return b;
  527.      
  528.   } 
  529. }
  530.  
  531. function _GetSubscriptionStatusClass(SubscriptionStatus)
  532. {
  533.   var  u = new ProductStatus();
  534.   switch ( SubscriptionStatus )
  535.     { 
  536.      case SubscriptionStatus_Good :
  537.       u.DivClass = "update_green";
  538.       u.StatusClass = "status green";
  539.       return u;
  540.       break;
  541.      case SubscriptionStatus_ExpireSoon :
  542.       u.DivClass = "update_orange";
  543.       u.StatusClass = "status yellow";
  544.       return u;
  545.      case SubscriptionStatus_Expired :
  546.       u.DivClass = "update_red";
  547.       u.StatusClass = "status red";
  548.       return u;
  549.      case SubscriptionStatus_Blue :
  550.       u.DivClass = "update_blue";
  551.       u.StatusClass = "status blue";
  552.       return u;
  553.   }
  554. }
  555.  
  556.  
  557.  
  558. //***********************************Set Language*************************//
  559. function SetLanguage (language)
  560. {
  561.      Get("aLOC_PerformNow").innerHTML = aLOC_PerformNow;
  562.      Get("spLOC_Tip_DeepAnalysis").innerHTML = spLOC_Tip_DeepAnalysis;
  563.      Get("spLOC_Tip_RestartRequired").innerHTML = spLOC_Tip_RestartRequired;
  564.      Get("aLOC_RestartNow").innerHTML = aLOC_RestartNow;
  565.       Get("spLOC_SubscriptionStatus").innerHTML = spLOC_SubscriptionStatus;
  566.      Get("aReAnalyzeLink").innerHTML=aReAnalyzeLink;
  567. }
  568.  
  569.  
  570.  
  571. //********** Test functions *******************
  572.  
  573. function test1()
  574. {
  575. AddOverviewTip("s", "sss", "XXXX");
  576. AddOverviewTip("s1", "sss1", "XXXX1");
  577.  
  578.  SetHintsAndTipsContent( "sdfsdf asdfasd fasdfasdf asdfasdfas dfdasf" )
  579.  
  580.  
  581.  SetOverallTackLevel("0");
  582.  
  583.  SetSubscriptionButtonID(2);
  584.  
  585.  
  586. SetSecurityTackLevel("0");
  587.  SetHealthTackLevel("0");
  588. // 
  589.  SetSystemStatusHeading("HHHHHHHH");
  590.  SetSystemStatusDetails("SDFDFSDFSDFDFD");
  591.  SetLastAnalysisText("Last analysis");
  592. // 
  593.  SetAnalyzeButtonVisible(false);
  594.  
  595.  SetSubscriptionDetailsText("SDFGSGSDFGSDFGDFGADFG");
  596.  SetRepairButtonVisible(false);
  597.  SetReanalyzeLinkVisible(true);
  598.  SetSubscriptionButtonVisible(true);
  599.  SetSubscriptionDetailsText("SSSSSSSSSSSSSSSSSSS");
  600. // SetDeepAnalysisTipVisible(true);
  601.  
  602. }
  603.  
  604. function test2()
  605. {
  606. SetHintsAndTipsHeight(200);
  607. SetHintsAndTipsVisible(true);
  608. SetOverviewTipVisible("s1", false);
  609. SetOverviewTipVisible("s", false);
  610.  
  611.  
  612.  SetOverallTackLevel("1");
  613.  SetHealthTackLevel("1");
  614. SetSecurityTackLevel("1");
  615.  
  616. //SetDeepAnalysisTipVisible(false);
  617.  
  618.  
  619.  SetRepairButtonVisible(false);
  620.  SetAnalyzeButtonVisible(false);
  621.   SetReanalyzeLinkVisible(false);
  622.  
  623.  SetSubscriptionButtonVisible(true);
  624. }
  625.  
  626. function test3()
  627. {
  628. SetOverviewTipVisible("s1", true);
  629. SetOverviewTipVisible("s", true);
  630.  
  631.  
  632.  SetOverallTackLevel("2");
  633.  SetHealthTackLevel("2");
  634. SetSecurityTackLevel("2");
  635.  
  636. }
  637.  
  638. function test4()
  639. {
  640. ClearOverviewTips();
  641.  
  642.  
  643. SetOverallTackLevel("3");
  644. SetHealthTackLevel("3");
  645. SetSecurityTackLevel("3");
  646.   SetRepairButtonVisible(true);
  647.   SetAnalyzeButtonVisible(true);
  648. }
  649.  
  650. function test5()
  651. {
  652. SetOverallTackLevel("4");
  653. SetHealthTackLevel("4");
  654. SetSecurityTackLevel("4");
  655.  
  656. }
  657.  
  658.  
  659.